<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class Off_play extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->checkUser($this->session->userdata('user_id'));
        $this->data['controller'] = 'off_play';
        $this->load->model('Moff_play');
        $data = array('loadaudio' => 0);
        $this->session->set_userdata($data);
    }
    
    public function index()
    {	
        $this->noteUserOff();
        $this->data['action'] = 'index';
        $this->load->view('template/layout', $this->data);
    }
    
    private function noteUserOff()
	{
		$this->session->userdata('user_id');
        $checkCoin = $this->Moff_play->checkCoin($this->session->userdata('user_id'));
    
        if($checkCoin != 200)
        {
            redirect('error-pay');
        }    
        
        $this->data['data'] = $this->Moff_play->noteUserOffDb($this->session->userdata('user_id'));
	}
	
	public function get_question(){
		$this->data['get_question']= $this->Moff_play->get_question_db();
		$this->data['action'] = 'get_question';
		 $this->load->view('template/off_play/get_question', $this->data);
	}
	
	public function check_answer(){
		$id = $this->getParamInt("id");
		$choice = $this->getParamInt("choice");
		$this->data['check_answer']= $this->Moff_play->check_answer($id,$choice);
		$this->data['action'] = 'check_answer';
		 $this->load->view('template/off_play/check_answer', $this->data);
	}
	
}
